package com.firstclass.controller;

import com.firstclass.entity.TakecourseEntity;
import com.firstclass.service.TakecourseService;
import com.firstclass.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 *
 *
 * @author
 * @email ${email}
 * @date 2021-12-09 15:41:30
 */
@RestController
@RequestMapping("/back/takecourse/")
public class TakecourseController {
    @Autowired
    private TakecourseService takecourseService;

    @GetMapping("find_takecourse")
    public String findTakeCourse(String name, String num, String grade) {
        return R.ok(takecourseService.queryByCondition(name, num, grade));
    }

    @GetMapping("update_status")
    public String updateStatus(Integer id, Integer flag) {
        takecourseService.updateStatusById(id, flag);
        return R.ok();
    }

    @PostMapping("save_course")
    public String saveCourse(@RequestBody TakecourseEntity takecourseEntity) {
        takecourseService.save(takecourseEntity);
        return R.ok();
    }

    @PostMapping("batch_del")
    public String batchDel(@RequestBody List<Integer> ids) {
        takecourseService.removeByIds(ids);
        return R.ok();
    }

}
